Completed
Push — release-2.1 ( 001348...ca7b71 )
by Mathias
18:55
created

extensionMethods.appendEmoticon   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 2
dl 0
loc 27
rs 8.8571
c 0
b 0
f 0
1
/**
2
 * Simple Machines Forum (SMF)
3
 *
4
 * @package SMF
5
 * @author Simple Machines http://www.simplemachines.org
6
 * @copyright 2017 Simple Machines and individual contributors
7
 * @license http://www.simplemachines.org/about/smf/license.php BSD
8
 *
9
 * @version 2.1 Beta 3
10
 */
11
12
(function ($) {
13
	var extensionMethods = {
14
		InsertText: function (text, bClear) {
15
			var bIsSource = this.inSourceMode();
16
17
			// @TODO make it put the quote close to the current selection
18
19
			if (!bIsSource)
20
				this.toggleSourceMode();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
21
22
			var current_value = bClear ? text : this.getSourceEditorValue(false) + text;
23
			this.setSourceEditorValue(current_value);
24
25
			if (!bIsSource)
26
				this.toggleSourceMode();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
27
28
		},
29
		getText: function (filter) {
30
			var current_value = '';
31
32
			if (this.inSourceMode())
33
				current_value = this.getSourceEditorValue(false);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
34
			else
35
				current_value  = this.getWysiwygEditorValue(filter);
36
37
			return current_value;
38
		},
39
		appendEmoticon: function (code, emoticon) {
40
			if (emoticon == '')
41
				line.append($('<br>'));
0 ignored issues
show
Bug introduced by
The variable line seems to be never declared. If this is a global, consider adding a /** global: line */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
42
			else
43
				line.append($('<img>')
44
					.attr({
45
						src: emoticon,
46
						alt: code,
47
					})
48
					.click(function (e) {
49
						var	start = '', end = '';
50
51
						if (base.opts.emoticonsCompat)
0 ignored issues
show
Bug introduced by
The variable base seems to be never declared. If this is a global, consider adding a /** global: base */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
52
						{
53
							start = '<span> ';
54
							end   = ' </span>';
55
						}
56
57
						if (base.inSourceMode())
58
							base.sourceEditorInsertText(' ' + $(this).attr('alt') + ' ');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
59
						else
60
							base.wysiwygEditorInsertHtml(start + '<img src="' + $(this).attr("src") + '" data-sceditor-emoticon="' + $(this).attr('alt') + '">' + end);
61
62
						e.preventDefault();
63
					})
64
				);
65
		},
66
		createPermanentDropDown: function () {
67
			var emoticons = $.extend({}, this.opts.emoticons.dropdown);
68
			var popup_exists = false;
69
			content = $('<div class="sceditor-insertemoticon">');
0 ignored issues
show
Bug introduced by
The variable content seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.content.
Loading history...
70
			line = $('<div>');
0 ignored issues
show
Bug introduced by
The variable line seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.line.
Loading history...
71
			base = this;
0 ignored issues
show
Bug introduced by
The variable base seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.base.
Loading history...
72
73
			for (smiley_popup in this.opts.emoticons.popup)
0 ignored issues
show
Bug introduced by
The variable smiley_popup seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.smiley_popup.
Loading history...
74
			{
75
				popup_exists = true;
76
				break;
77
			}
78
			if (popup_exists)
79
			{
80
				base.opts.emoticons.more = base.opts.emoticons.popup;
81
				moreButton = $('<div class="sceditor-more-button sceditor-more button">').text(this._('More')).click(function () {
0 ignored issues
show
Bug introduced by
The variable moreButton seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.moreButton.
Loading history...
82
					if ($(".sceditor-smileyPopup").length > 0)
83
					{
84
						$(".sceditor-smileyPopup").fadeIn('fast');
85
					}
86
					else
87
					{
88
						var emoticons = $.extend({}, base.opts.emoticons.popup);
89
						var popup_position;
0 ignored issues
show
Unused Code introduced by
The variable popup_position seems to be never used. Consider removing it.
Loading history...
90
						var titlebar = $('<div class="catbg sceditor-popup-grip"/>');
91
						popupContent = $('<div id="sceditor-popup"/>');
0 ignored issues
show
Bug introduced by
The variable popupContent seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.popupContent.
Loading history...
92
						allowHide = true;
0 ignored issues
show
Bug introduced by
The variable allowHide seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.allowHide.
Loading history...
93
						line = $('<div id="sceditor-popup-smiley"/>');
0 ignored issues
show
Bug introduced by
The variable line seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.line.
Loading history...
94
						adjheight = 0;
0 ignored issues
show
Bug introduced by
The variable adjheight seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.adjheight.
Loading history...
95
96
						popupContent.append(titlebar);
97
						closeButton = $('<span class="button">').text(base._('Close')).click(function () {
0 ignored issues
show
Bug introduced by
The variable closeButton seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.closeButton.
Loading history...
98
							$(".sceditor-smileyPopup").fadeOut('fast');
99
						});
100
101
						$.each(emoticons, base.appendEmoticon);
102
103
						if (line.children().length > 0)
104
							popupContent.append(line);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
105
						if (typeof closeButton !== "undefined")
106
							popupContent.append(closeButton);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
107
108
						// IE needs unselectable attr to stop it from unselecting the text in the editor.
109
						// The editor can cope if IE does unselect the text it's just not nice.
110
						if (base.ieUnselectable !== false) {
111
							content = $(content);
0 ignored issues
show
Bug introduced by
The variable content seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.content.
Loading history...
112
							content.find(':not(input,textarea)').filter(function () { return this.nodeType===1; }).attr('unselectable', 'on');
113
						}
114
115
						dropdownIgnoreLastClick = true;
0 ignored issues
show
Bug introduced by
The variable dropdownIgnoreLastClick seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.dropdownIgnoreLastClick.
Loading history...
116
						adjheight = closeButton.height() + titlebar.height();
0 ignored issues
show
Bug introduced by
The variable adjheight seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.adjheight.
Loading history...
117
						$dropdown = $('<div class="centerbox sceditor-smileyPopup">')
0 ignored issues
show
Bug introduced by
The variable $dropdown seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.$dropdown.
Loading history...
118
							.append(popupContent)
119
							.appendTo($('.sceditor-container'));
120
121
						$('.sceditor-smileyPopup').animaDrag({
122
							speed: 150,
123
							interval: 120,
124
							during: function (e) {
0 ignored issues
show
Unused Code introduced by
The parameter e is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
125
								$(this).height(this.startheight);
126
								$(this).width(this.startwidth);
127
							},
128
							before: function (e) {
0 ignored issues
show
Unused Code introduced by
The parameter e is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
129
								this.startheight = $(this).innerHeight();
130
								this.startwidth = $(this).innerWidth();
131
							},
132
							grip: '.sceditor-popup-grip'
133
						});
134
						// stop clicks within the dropdown from being handled
135
						$dropdown.click(function (e) {
136
							e.stopPropagation();
137
						});
138
					}
139
				});
140
			}
141
			$.each(emoticons, base.appendEmoticon);
142
			if (line.children().length > 0)
143
				content.append(line);
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
144
			$(".sceditor-toolbar").append(content);
145
			if (typeof moreButton !== "undefined")
0 ignored issues
show
Bug introduced by
The variable moreButton does not seem to be initialized in case popup_exists on line 78 is false. Are you sure this can never be the case?
Loading history...
146
				content.append($('<center/>').append(moreButton));
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
147
		}
148
	};
149
150
	$.extend(true, $['sceditor'].prototype, extensionMethods);
151
})(jQuery);
152
153
$.sceditor.command.set(
154
	'pre', {
155
		tooltip: 'Pre',
156
		txtExec: ["[pre]", "[/pre]"],
157
		exec: function () {
158
			this.wysiwygEditorInsertHtml('<pre>', '</pre>');
159
		}
160
	}
161
);
162
$.sceditor.command.set(
163
	'email', {
164
		txtExec: function (caller, selected) {
165
			var	display = selected && selected.indexOf('@') > -1 ? null : selected,
166
				email	= prompt(this._("Enter the e-mail address:"), (display ? '' : selected));
167
			if (email)
168
			{
169
				var text	= prompt(this._("Enter the displayed text:"), display || email) || email;
170
				this.insertText("[email=" + email + "]" + text + "[/email]");
171
			}
172
		}
173
	}
174
);
175
$.sceditor.command.set(
176
	'link', {
177
		txtExec: function (caller, selected) {
178
			var	display = selected && selected.indexOf('http://') > -1 ? null : selected,
179
				url	= prompt(this._("Enter URL:"), (display ? 'http://' : selected));
180
			if (url)
181
			{
182
				var text	= prompt(this._("Enter the displayed text:"), display || url) || url;
183
				this.insertText("[url=\"" + url + "\"]" + text + "[/url]");
184
			}
185
		}
186
	}
187
);
188
189
$.sceditor.command.set(
190
	'bulletlist', {
191
		txtExec: function (caller, selected) {
192
			if (selected)
193
			{
194
				var content = '';
195
196
				$.each(selected.split(/\r?\n/), function () {
197
					content += (content ? '\n' : '') + '[li]' + this + '[/li]';
198
				});
199
200
				this.insertText('[list]\n' + content + '\n[/list]');
201
			}
202
			else
203
				this.insertText('[list]\n[li]', '[/li]\n[li][/li]\n[/list]');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
204
		}
205
	}
206
);
207
208
$.sceditor.command.set(
209
	'orderedlist', {
210
		txtExec:  function (caller, selected) {
211
			if (selected)
212
			{
213
				var content = '';
214
215
				$.each(selected.split(/\r?\n/), function () {
216
					content += (content ? '\n' : '') + '[li]' + this + '[/li]';
217
				});
218
219
				this.insertText('[list type=decimal]\n' + content + '\n[/list]');
220
			}
221
			else
222
				this.insertText('[list type=decimal]\n[li]', '[/li]\n[li][/li]\n[/list]');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
223
		}
224
	}
225
);
226
227
$.sceditor.command.set(
228
	'table', {
229
		txtExec: ["[table]\n[tr]\n[td]", "[/td]\n[/tr]\n[/table]"]
230
	}
231
);
232
233
$.sceditor.command.set(
234
	'floatleft', {
235
		tooltip: 'Float left',
236
		txtExec: ["[float=left max=45%]", "[/float]"],
237
		exec: function () {
238
			this.wysiwygEditorInsertHtml('<div class="floatleft">', '</div>');
239
		}
240
	}
241
);
242
243
$.sceditor.command.set(
244
	'floatright', {
245
		tooltip: 'Float right',
246
		txtExec: ["[float=right max=45%]", "[/float]"],
247
		exec: function () {
248
			this.wysiwygEditorInsertHtml('<div class="floatright">', '</div>');
249
		}
250
	}
251
);
252
253
$.sceditor.plugins.bbcode.bbcode.set(
254
	'abbr', {
255
		tags: {
256
			abbr: {
257
				title: null
258
			}
259
		},
260
		format: function (element, content) {
261
			return '[abbr=' + element.attr('title') + ']' + content + '[/abbr]';
262
		},
263
		html: function (element, attrs, content) {
264
			if (typeof attrs.defaultattr === "undefined" || attrs.defaultattr.length === 0)
265
				return content;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
266
267
			return '<abbr title="' + attrs.defaultattr + '">' + content + '</abbr>';
268
		}
269
	}
270
);
271
272
$.sceditor.plugins.bbcode.bbcode.set(
273
	'list', {
274
		breakStart: true,
275
		isInline: false,
276
		allowedChildren: ['*', 'li'],
277
		html: function (element, attrs, content) {
278
			var style = '';
279
			var code = 'ul';
280
			var olTypes = new Array('decimal', 'decimal-leading-zero', 'lower-roman', 'upper-roman', 'lower-alpha', 'upper-alpha', 'lower-greek', 'upper-greek', 'lower-latin', 'upper-latin', 'hebrew', 'armenian', 'georgian', 'cjk-ideographic', 'hiragana', 'katakana', 'hiragana-iroha', 'katakana-iroha');
0 ignored issues
show
Coding Style Best Practice introduced by
Using the Array constructor is generally discouraged. Consider using an array literal instead.
Loading history...
281
282
			if (attrs.type) {
283
				style = ' style="list-style-type: ' + attrs.type + '"';
284
285
				if (olTypes.indexOf(attrs.type) > -1)
286
					code = 'ol';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
287
			}
288
			else
289
				style = ' style="list-style-type: disc"';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
290
291
			return '<' + code + style + '>' + content + '</' + code + '>';
292
		}
293
	}
294
);
295
296
$.sceditor.plugins.bbcode.bbcode.set(
297
	'ul', {
298
		tags: {
299
			ul: null
300
		},
301
		breakStart: true,
302
		isInline: false,
303
		html: '<ul>{0}</ul>',
304
		format: function (element, content) {
305
			if ($(element[0]).css('list-style-type') == 'disc')
306
				return '[list]' + content + '[/list]';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
307
			else
308
				return '[list type=' + $(element[0]).css('list-style-type') + ']' + content + '[/list]';
309
		}
310
	}
311
);
312
313
$.sceditor.plugins.bbcode.bbcode.set(
314
	'ol', {
315
		tags: {
316
			ol: null
317
		},
318
		breakStart: true,
319
		isInline: false,
320
		html: '<ol>{0}</ol>',
321
		format: function (element, content) {
322
			if ($(element[0]).css('list-style-type') == 'none')
323
				return '[list type=decimal]' + content + '[/list]';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
324
			else
325
				return '[list type=' + $(element[0]).css('list-style-type') + ']' + content + '[/list]';
326
		}
327
	}
328
);
329
330
$.sceditor.plugins.bbcode.bbcode.set(
331
	'img', {
332
		tags: {
333
			img: {
334
				src: null
335
			}
336
		},
337
		allowsEmpty: true,
338
		quoteType: $.sceditor.BBCodeParser.QuoteType.never,
339
		format: function (element, content) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
340
			var	attribs = '',
341
				style = function (name) {
342
					return element.style ? element.style[name] : null;
343
				};
344
345
			// check if this is an emoticon image
346
			if (typeof element.attr('data-sceditor-emoticon') !== "undefined")
347
				return content;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
348
349
			// only add width and height if one is specified
350
			if (element.attr('width') || style('width'))
351
				attribs += " width=" + $(element).width();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
352
			if (element.attr('height') || style('height'))
353
				attribs += " height=" + $(element).height();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
354
			if (element.attr('alt'))
355
				attribs += " alt=" + element.attr('alt');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
356
357
			// Is this an attachment?
358
			if (element.attr('data-attachment'))
359
			{
360
				if (element.attr('title'))
361
					attribs += ' name=' + element.attr('title');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
362
				if (element.attr('data-type'))
363
					attribs += ' type=' + 	element.attr('data-type');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
364
365
				return '[attach' + attribs + ']' + element.attr('data-attachment') + '[/attach]';
366
			}
367
			else if (element.attr('title'))
368
				attribs += " title=" + element.attr('title');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
369
370
			return '[img' + attribs + ']' + element.attr('src') + '[/img]';
371
		},
372
		html: function (token, attrs, content) {
373
			var	parts,
0 ignored issues
show
Unused Code introduced by
The variable parts seems to be never used. Consider removing it.
Loading history...
374
				attribs = '';
375
376
			// handle [img width=340 height=240]url[/img]
377
			if (typeof attrs.width !== "undefined")
378
				attribs += ' width="' + attrs.width + '"';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
379
			if (typeof attrs.height !== "undefined")
380
				attribs += ' height="' + attrs.height + '"';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
381
			if (typeof attrs.alt !== "undefined")
382
				attribs += ' alt="' + attrs.alt + '"';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
383
			if (typeof attrs.title !== "undefined")
384
				attribs += ' title="' + attrs.title + '"';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
385
386
			return '<img' + attribs + ' src="' + content + '">';
387
		}
388
	}
389
);
390
391
$.sceditor.plugins.bbcode.bbcode.set(
392
	'attach', {
393
		tags: {
394
			attach: {
395
				src: null
396
			}
397
		},
398
		allowsEmpty: true,
399
		quoteType: $.sceditor.BBCodeParser.QuoteType.never,
400
		format: function (element, content) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
401
			var	attribs = '',
402
				style = function (name) {
403
					return element.style ? element.style[name] : null;
404
				};
405
406
			// only add width and height if one is specified
407
			if (element.attr('width') || style('width'))
408
				attribs += " width=" + $(element).width();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
409
			if (element.attr('height') || style('height'))
410
				attribs += " height=" + $(element).height();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
411
			if (element.attr('alt'))
412
				attribs += " alt=" + element.attr('alt');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
413
			if (element.attr('title'))
414
				attribs += " name=" + element.attr('title');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
415
			if (element.attr('data-type'))
416
				attribs += " type=" + element.attr('data-type');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
417
418
			return '[attach' + attribs + ']' + (element.attr('data-attachment') ? element.attr('data-attachment') : content) + '[/attach]';
419
		},
420
		html: function (token, attrs, id) {
421
			var parts,
0 ignored issues
show
Unused Code introduced by
The variable parts seems to be never used. Consider removing it.
Loading history...
422
				attribs = '';
423
424
			// If id is not an integer, bail out
425
			if (!$.isNumeric(id) || Math.floor(id) != +id || +id <= 0) {
426
427
				if (typeof attrs.width !== "undefined")
428
					attribs += ' width=' + attrs.width;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
429
				if (typeof attrs.height !== "undefined")
430
					attribs += ' height=' + attrs.height;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
431
				if (typeof attrs.alt !== "undefined")
432
					attribs += ' alt=' + attrs.alt;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
433
				if (typeof attrs.name !== "undefined")
434
					attribs += ' name=' + attrs.name;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
435
				if (typeof attrs.type !== "undefined")
436
					attribs += ' type=' + attrs.type;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
437
438
				return '[attach' + attribs + ']' + id + '[/attach]';
439
			}
440
441
			attribs += ' data-attachment="' + id + '"'
442
			if (typeof attrs.width !== "undefined")
443
				attribs += ' width="' + attrs.width + '"';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
444
			if (typeof attrs.height !== "undefined")
445
				attribs += ' height="' + attrs.height + '"';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
446
			if (typeof attrs.alt !== "undefined")
447
				attribs += ' alt="' + attrs.alt + '"';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
448
			if (typeof attrs.type !== "undefined")
449
				attribs += ' data-type="' + attrs.type + '"';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
450
			if (typeof attrs.name !== "undefined")
451
				attribs += ' title="' + attrs.name + '"';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
452
453
			// Is this an image?
454
			if ((typeof attrs.type !== "undefined" && attrs.type.indexOf("image") === 0)) {
455
				var contentUrl = smf_scripturl +'?action=dlattach;attach='+ id + ';type=preview;thumb';
0 ignored issues
show
Bug introduced by
The variable smf_scripturl seems to be never declared. If this is a global, consider adding a /** global: smf_scripturl */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
456
				contentIMG = new Image();
0 ignored issues
show
Bug introduced by
The variable Image seems to be never declared. If this is a global, consider adding a /** global: Image */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Bug introduced by
The variable contentIMG seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.contentIMG.
Loading history...
457
					contentIMG.src = contentUrl;
458
			}
459
460
			// If not an image, show a boring ol' link
461
			if (typeof contentUrl === "undefined" || contentIMG.getAttribute('width') == 0)
0 ignored issues
show
Bug introduced by
The variable contentUrl does not seem to be initialized in case typeof attrs.type !== "....indexOf("image") === 0 on line 454 is false. Are you sure this can never be the case?
Loading history...
Bug introduced by
The variable contentIMG does not seem to be initialized in case typeof attrs.type !== "....indexOf("image") === 0 on line 454 is false. Are you sure this can never be the case?
Loading history...
462
				return '<a href="' + smf_scripturl + '?action=dlattach;attach=' + id + ';type=preview;file"' + attribs + '>' + (typeof attrs.name !== "undefined" ? attrs.name : id) + '</a>';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
463
			// Show our purdy li'l picture
464
			else
465
				return '<img' + attribs + ' src="' + contentUrl + '">';
466
		}
467
	}
468
);
469
470
$.sceditor.plugins.bbcode.bbcode.set(
471
	'url', {
472
		allowsEmpty: true,
473
		quoteType: $.sceditor.BBCodeParser.QuoteType.never,
474
		tags: {
475
			a: {
476
				href: null
477
			}
478
		},
479
		format: function (element, content) {
480
			var url = element.attr('href');
481
482
			// make sure this link is not an e-mail, if it is return e-mail BBCode
483
			if (url.substr(0, 7) === 'mailto:')
484
				return '[email=' + url.substr(7) + ']' + content + '[/email]';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
485
486
			if (typeof element.attr('target') !== "undefined")
487
				return '[url=\"' + decodeURI(url) + '\"]' + content + '[/url]';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
488
489
			// A mention?
490
			else if (typeof element.attr('data-mention') !== "undefined")
491
			{
492
				return '[member='+ element.attr('data-mention') +']'+ content.replace('@','') +'[/member]';
493
			}
494
495
			// Is this an attachment?
496
			else if (typeof element.attr('data-attachment') !== "undefined")
497
			{
498
				var attribs = '';
499
				if (typeof element.attr('title') !== "undefined")
500
					attribs += ' name=' + element.attr('title');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
501
				if (typeof element.attr('data-type') !== "undefined")
502
					attribs += ' type=' + element.attr("data-type");
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
503
504
				return '[attach' + attribs + ']' + element.attr('data-attachment') + '[/attach]';
505
			}
506
507
			else
508
				return '[iurl=\"' + decodeURI(url) + '\"]' + content + '[/iurl]';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
509
		},
510
		html: function (token, attrs, content) {
511
			if (typeof attrs.defaultattr === "undefined" || attrs.defaultattr.length === 0)
512
				attrs.defaultattr = content;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
513
514
			return '<a target="_blank" href="' + encodeURI(attrs.defaultattr) + '">' + content + '</a>';
515
		}
516
	}
517
);
518
519
$.sceditor.plugins.bbcode.bbcode.set(
520
	'iurl', {
521
		allowsEmpty: true,
522
		quoteType: $.sceditor.BBCodeParser.QuoteType.never,
523
		html: function (token, attrs, content) {
524
525
			if (typeof attrs.defaultattr === "undefined" || attrs.defaultattr.length === 0)
526
				attrs.defaultattr = content;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
527
528
			return '<a href="' + encodeURI(attrs.defaultattr) + '">' + content + '</a>';
529
		}
530
	}
531
);
532
533
$.sceditor.plugins.bbcode.bbcode.set(
534
	'pre', {
535
		tags: {
536
			pre: null
537
		},
538
		isBlock: true,
539
		format: "[pre]{0}[/pre]",
540
		html: "<pre>{0}</pre>\n"
541
	}
542
);
543
544
$.sceditor.plugins.bbcode.bbcode.set(
545
	'php', {
546
		isInline: false,
547
		format: "[php]{0}[/php]",
548
		html: '<code class="php">{0}</code>'
549
	}
550
);
551
552
$.sceditor.plugins.bbcode.bbcode.set(
553
	'code', {
554
		tags: {
555
			code: null
556
		},
557
		isInline: false,
558
		allowedChildren: ['#', '#newline'],
559
		format: function (element, content) {
560
			if ($(element[0]).hasClass('php'))
561
				return '[php]' + content.replace('&#91;', '[') + '[/php]';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
562
563
			var from = '';
564
			if ($(element).children("cite:first").length === 1)
565
			{
566
				from = $(element).children("cite:first").text();
567
568
				$(element).attr({'from': from.php_htmlspecialchars()});
569
570
				from = '=' + from;
571
				content = '';
0 ignored issues
show
Unused Code introduced by
The assignment to variable content seems to be never used. Consider removing it.
Loading history...
572
				$(element).children("cite:first").remove();
573
				content = this.elementToBbcode($(element));
574
			}
575
			else
576
			{
577
				if (typeof $(element).attr('from') != 'undefined')
578
				{
579
					from = '=' + $(element).attr('from').php_unhtmlspecialchars();
580
				}
581
			}
582
583
			return '[code' + from + ']' + content.replace('&#91;', '[') + '[/code]';
584
585
		},
586
		html: function (element, attrs, content) {
587
			var from = '';
588
			if (typeof attrs.defaultattr !== "undefined")
589
				from = '<cite>' + attrs.defaultattr + '</cite>';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
590
591
			return '<code>' + from + content.replace('[', '&#91;') + '</code>'
592
		}
593
	}
594
);
595
596
$.sceditor.plugins.bbcode.bbcode.set(
597
	'quote', {
598
		tags: {
599
			blockquote: null,
600
			cite: null
601
		},
602
		quoteType: $.sceditor.BBCodeParser.QuoteType.never,
603
		breakBefore: false,
604
		isInline: false,
605
		format: function (element, content) {
606
			var author = '';
607
			var date = '';
608
			var link = '';
609
610
			// The <cite> contains only the graphic for the quote, so we can skip it
611
			if (element[0].tagName.toLowerCase() === 'cite')
612
				return '';
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
613
614
			if (element.attr('author'))
615
				author = ' author=' + element.attr('author').php_unhtmlspecialchars();
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
616
			if (element.attr('link'))
617
				link = ' link=' + element.attr('link');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
618
			if (element.attr('date'))
619
				date = ' date=' + element.attr('date');
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
620
621
			return '[quote' + author + link + date + ']' + content + '[/quote]';
622
		},
623
		html: function (element, attrs, content) {
624
			var attr_author = '', author = '';
625
			var attr_date = '', sDate = '';
626
			var attr_link = '', link = '';
627
628
			if (typeof attrs.author !== "undefined" && attrs.author)
629
			{
630
				attr_author = attrs.author;
631
				author = bbc_quote_from + ': ' + attr_author;
0 ignored issues
show
Bug introduced by
The variable bbc_quote_from seems to be never declared. If this is a global, consider adding a /** global: bbc_quote_from */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
632
			}
633
634
			// Links could be in the form: link=topic=71.msg201#msg201 that would fool javascript, so we need a workaround
635
			// Probably no more necessary
636
			for (var key in attrs)
0 ignored issues
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
637
			{
638
				if (key.substr(0, 4) == 'link' && attrs.hasOwnProperty(key))
639
				{
640
					var attr_link = key.length > 4 ? key.substr(5) + '=' + attrs[key] : attrs[key];
0 ignored issues
show
Comprehensibility Naming Best Practice introduced by
The variable attr_link already seems to be declared on line 626. Consider using another variable name or omitting the var keyword.

This check looks for variables that are declared in multiple lines. There may be several reasons for this.

In the simplest case the variable name was reused by mistake. This may lead to very hard to locate bugs.

If you want to reuse a variable for another purpose, consider declaring it at or near the top of your function and just assigning to it subsequently so it is always declared.

Loading history...
641
642
					link = attr_link.substr(0, 7) == 'http://' ? attr_link : smf_scripturl + '?' + attr_link;
0 ignored issues
show
Bug introduced by
The variable smf_scripturl seems to be never declared. If this is a global, consider adding a /** global: smf_scripturl */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
643
					author = author == '' ? '<a href="' + link + '">' + bbc_quote_from + ': ' + link + '</a>' : '<a href="' + link + '">' + author + '</a>';
644
				}
645
			}
646
647
			if (typeof attrs.date !== "undefined" && attrs.date)
648
			{
649
				attr_date = attrs.date;
650
				sDate = '<date timestamp="' + attr_date + '">' + new Date(attrs.date * 1000) + '</date>';
651
			}
652
653
			if (author == '' && sDate == '')
654
				author = bbc_quote;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
Bug introduced by
The variable bbc_quote seems to be never declared. If this is a global, consider adding a /** global: bbc_quote */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
655
			else if (author == '' && sDate != '')
656
				author += ' ' + bbc_search_on;
0 ignored issues
show
Bug introduced by
The variable bbc_search_on seems to be never declared. If this is a global, consider adding a /** global: bbc_search_on */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
657
658
			content = '<blockquote author="' + attr_author + '" date="' + attr_date + '" link="' + attr_link + '"><cite>' + author + ' ' + sDate + '</cite>' + content + '</blockquote>';
659
660
			return content;
661
		}
662
	}
663
);
664
665
$.sceditor.plugins.bbcode.bbcode.set('font', {
666
	format: function ($element, content) {
667
		var font;
668
669
		// Get the raw font value from the DOM
670
		if (!$element.is('font') || !(font = $element.attr('face'))) {
671
			font = $element.css('font-family');
672
		}
673
674
		// Strip all quotes
675
		font = font.replace(/['"]/g, '');
676
677
		return '[font=' + font + ']' + content + '[/font]';
678
	}
679
});
680
681
$.sceditor.plugins.bbcode.bbcode.set(
682
	'member', {
683
		isInline: true,
684
		format: function ($element, content) {
685
			return '[member='+ $element.attr('data-mention') +']'+ content.replace('@','') +'[/member]';
686
		},
687
		html: function (token, attrs, content) {
688
			if (typeof attrs.defaultattr === "undefined" || attrs.defaultattr.length === 0)
689
				attrs.defaultattr = content;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
690
691
			return '<a href="' + smf_scripturl +'?action=profile;u='+ attrs.defaultattr + '" class="mention" data-mention="'+ attrs.defaultattr + '">@'+ content.replace('@','') +'</a>';
0 ignored issues
show
Bug introduced by
The variable smf_scripturl seems to be never declared. If this is a global, consider adding a /** global: smf_scripturl */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
692
		}
693
	}
694
);
695
696
$.sceditor.plugins.bbcode.bbcode.set(
697
	'float', {
698
		tags: {
699
			div: {
700
				"class": ["floatleft", "floatright"],
701
			},
702
		},
703
		isInline: false,
704
		skipLastLineBreak: true,
705
		format: function ($element, content) {
706
			if (!$element.css('float'))
707
				return content;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
708
709
			side = ($element.css('float').indexOf('left') == 0 ? 'left' : 'right');
0 ignored issues
show
Bug introduced by
The variable side seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.side.
Loading history...
710
			max = ' max=' + ($element.css('max-width') != "none" ? $element.css('max-width') : '45%');
0 ignored issues
show
Bug introduced by
The variable max seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.max.
Loading history...
711
712
			return '[float=' + side + max + ']' + content + '[/float]';
713
		},
714
		html: function (token, attrs, content) {
715
			if (typeof attrs.defaultattr === "undefined")
716
				return content;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
717
718
			floatclass = attrs.defaultattr.indexOf('left') == 0 ? 'floatleft' : 'floatright';
0 ignored issues
show
Bug introduced by
The variable floatclass seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.floatclass.
Loading history...
719
			style = typeof attrs.max !== "undefined" ? ' style="max-width:' + attrs.max + (+attrs.max === parseInt(attrs.max) ? 'px' : '') + ';"' : '';
0 ignored issues
show
Bug introduced by
The variable style seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.style.
Loading history...
720
721
			return '<div class="' + floatclass + '"' + style + '>' + content + '</div>';
722
		}
723
	}
724
);
725